/*
 * @Author: ZechariahZheng
 * @Date: 2021-11-15 11:10:54
 * @LastEditors: ZechariahZheng
 * @LastEditTime: 2022-02-10 15:21:44
 * @Description: 请填写简介
 */
const state = ({      //state里面存放的是变量，如果你要注册全局变量，写这里
    tabbarIndex: 0,
    tabbarNumForWork: 0,
    workAllBadge: {},       //办公页面badge
});

const getters = {                //getters相当于是state的计算属性，如果你需要将变量的值进行计算，然后输出，写这里
    getTabbarIndex(state) {
        return state.tabbarIndex;
    },
    getTabbarNumForWork(state) {
        return state.tabbarNumForWork;
    },
    getWorkAllBadge(state) {
        return state.workAllBadge;
    }
};

const mutations = {       //修改store中的变量的方法，如果你要改变变量的值，就写这里
    SET_tabbarIndex(state, value) {
        state.tabbarIndex = value;
    },
    SET_tabbarNumForWork(state, value) {
        state.tabbarNumForWork = value;
    },
    SET_workAllBadge(state, key, value) {
        state.workAllBadge[key] = value;
    }
};

const actions = {            //actions提交的是mutations，相当于就是改变变量的方法的重写，但是，actions是可以进行异步操作的
    setTabbarIndex(content, value) {
        content.commit('SET_tabbarIndex', value);
    },
    setTabbarNumForWork(content, value) {
        content.commit('SET_tabbarNumForWork', value);
    },
    setWorkAllBadge(content, key, value) {
        content.commit('SET_workAllBadge', key, value);
    }
};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};